<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/7/12
 * Time: 下午10:09
 */

namespace app\admin\controller;


use think\Request;

class Order extends Auth
{
    /**
     * @purpose 获取订单列表
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function items (Request $request)
    {
        $page       = $request->get('page', 1);
        $size       = $request->get('size', 40);
        $status     = (int) $request->get('status');
        $kw         = $request->get('kw', '');
        $search_type= $request->get('search_type', 0);
        $where      = [];
        if ($status !== 99) {
            $where['status']      = $status;
        }
        return \app\admin\logic\Order::items($where,$page,$size, $kw, $search_type);
    }

    /**
     * @purpose 订单发货
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function deliverGoods (Request $request)
    {
        $data       = $request->post();
        return \app\admin\logic\Order::deliverGoods($data, self::$user_info['uid']);
    }

    /**
     * @purpose 通过ID获取订单详情
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function detailById (Request $request)
    {
        $id         = $request->get('id');
        return \app\admin\logic\Order::detailById($id);
    }
}